/**
 * This class creates the standard imageIcons from some images...
 */
package no.eirikb.bomberman.shared.img;

import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Hashtable;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import no.eirikb.bomberman.shared.DB;

/**
 *
 * @author eirikb
 */
public class CreateImageDB {

    public static void main(String[] args) {
        //generate pix! oh blah.. lotsowork...
        try {
            ImageDB idb = new ImageDB();

            ImgCharacter c = new ImgCharacter();
            c.addLeft(new ImageIcon(ImageIO.read(new File("img/ml1.png"))));
            c.addLeft(new ImageIcon(ImageIO.read(new File("img/ml2.png"))));
            c.addLeft(new ImageIcon(ImageIO.read(new File("img/ml3.png"))));

            c.addUp(new ImageIcon(ImageIO.read(new File("img/mu1.png"))));
            c.addUp(new ImageIcon(ImageIO.read(new File("img/mu2.png"))));

            c.addDown(new ImageIcon(ImageIO.read(new File("img/md1.png"))));
            c.addDown(new ImageIcon(ImageIO.read(new File("img/md2.png"))));

            idb.addCharacter("default", c);



            ImgFire f = new ImgFire();

            f.addCore(new ImageIcon(ImageIO.read(new File("img/boomcore1.png"))));
            f.addCore(new ImageIcon(ImageIO.read(new File("img/boomcore2.png"))));
            f.addCore(new ImageIcon(ImageIO.read(new File("img/boomcore3.png"))));
            f.addCore(new ImageIcon(ImageIO.read(new File("img/boomcore4.png"))));

            f.addSide1(new ImageIcon(ImageIO.read(new File("img/boomside1.png"))));
            f.addSide1(new ImageIcon(ImageIO.read(new File("img/boomside2.png"))));
            f.addSide1(new ImageIcon(ImageIO.read(new File("img/boomside3.png"))));
            f.addSide1(new ImageIcon(ImageIO.read(new File("img/boomside4.png"))));

            f.addLeft(new ImageIcon(ImageIO.read(new File("img/boomend1.png"))));
            f.addLeft(new ImageIcon(ImageIO.read(new File("img/boomend2.png"))));
            f.addLeft(new ImageIcon(ImageIO.read(new File("img/boomend3.png"))));
            f.addLeft(new ImageIcon(ImageIO.read(new File("img/boomend4.png"))));

            idb.addFire("default", f);


            ArrayList<ImageIcon> lol2 = new ArrayList<ImageIcon>();

            lol2.add(new ImageIcon(ImageIO.read(new File("img/bomb1.png"))));
            lol2.add(new ImageIcon(ImageIO.read(new File("img/bomb1.png"))));
            lol2.add(new ImageIcon(ImageIO.read(new File("img/bomb1.png"))));

            Hashtable<String, ArrayList<ImageIcon>> lol = new Hashtable<String, ArrayList<ImageIcon>>();
            lol.put("default", lol2);
            idb.setBomb(lol);

            lol2 = new ArrayList<ImageIcon>();

            lol2.add(new ImageIcon(ImageIO.read(new File("img/brick.png"))));
            lol2.add(new ImageIcon(ImageIO.read(new File("img/boombrick1.png"))));
            lol2.add(new ImageIcon(ImageIO.read(new File("img/boombrick2.png"))));

            lol = new Hashtable<String, ArrayList<ImageIcon>>();
            lol.put("default", lol2);
            idb.setBrick(lol);



            Hashtable<String, ImageIcon> lol3 = new Hashtable<String, ImageIcon>();
            ImageIcon i = new ImageIcon(ImageIO.read(new File("img/box.png")));
            lol3.put("default", i);
            idb.setBox(lol3);



            lol3 = new Hashtable<String, ImageIcon>();
            i = new ImageIcon(ImageIO.read(new File("img/pu1.png")));
            lol3.put("default", i);
            idb.setPowerup(lol3);

            DB db = new DB();
            idb.setWelcome(new ImageIcon(ImageIO.read(new File("img/bg.png"))));
            db.setIdb(idb);
            save("db", db);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void save(String name, Object o) {
        try {
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name));
            out.writeObject(o);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
